#ifndef __TLB_H__
#define __TLB_H__
#include "nemu.h"
#include "memory.h"
#include <stdlib.h>

#define TLB_SIZE 64

typedef struct TLB_Block {
	struct {
		uint32_t valid: 1;
		uint32_t tag : 20;
	};
	hwaddr_t page_frame;
} TLB_Block;

typedef struct TLB_t {
	TLB_Block ctnr[TLB_SIZE];

	void (*init)(struct TLB_t *);
	hwaddr_t (*read)(struct TLB_t *, lnaddr_t, bool *);
	void (*write)(struct TLB_t *, lnaddr_t, hwaddr_t);
	void (*flush)(struct TLB_t *);
	void (*disp)(struct TLB_t *);
} TLB_t;

TLB_t tlb;

void init_tlb();

#endif //__TLB_H__
